package com.gitee.cui.springcloud.storage.controller;

import javax.annotation.Resource;

import com.gitee.cui.springcloud.storage.domain.CommonResult;
import com.gitee.cui.springcloud.storage.service.StorageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 减库存服务
 *
 * @author cuiqingqiang
 * @version 1.0
 * @date 2022-03-26 15:24
 **/
@RestController
@Slf4j
@RequestMapping("/storage")
public class StorageController {

	@Resource
	private StorageService storageService;

	@PostMapping("/decrease")
	public CommonResult decrease(@RequestParam("productId") Long productId, @RequestParam("count") Integer count) {
		storageService.decrease(productId, count);
		return new CommonResult(200, "减库存数量：" + count + "，成功");
	}
}
